﻿using System;
using System.Collections.Generic;
using System.Linq;
using Contacts;

namespace Contacts
{
    public class ErrorHandling
    {
        public static void ErrorEmail(string subject, Exception ex)
        {
            string table = string.Format(@"<html><head><title>Error Reporting</title>
                <link rel=""stylesheet"" type=""text/css"" href=""C:\Projects\Outlook Connect\Outlook Connect\CSS\errortablestyle.css""/>
                </head><table><tr><td align=""right"" width=""10%"" style=""font-weight: bold;"">Message:</td><td>""{0}""</td></tr><tr><td align=""right"" style=""font-weight: bold;"">Source: </td>
                <td>""{1}""</td></tr><tr><td align=""right"" style=""font-weight: bold;"">Stack Trace: </td><td>""{2}""</td></tr><tr>
                <td align=""right"" style=""font-weight: bold;"">Target Site: </td><td>""{3}""</td></tr></table>
                </html>", ex.Message, ex.Source, ex.StackTrace, ex.TargetSite); mailman.sendmail(subject, table);
        }
    }
}
